//
//  YDOACostApplyCell.swift
//  YDOAProduct
//
//  Created by 占益民 on 2017/11/9.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit

class YDOACostApplyCell: UITableViewCell {

    @IBOutlet weak var remarkLb: UILabel!
    @IBOutlet weak var securityLb: UILabel!
    @IBOutlet weak var applyTimeLb: UILabel!
    @IBOutlet weak var abstractLb: UILabel!
    @IBOutlet weak var despartmentLb: UILabel!
    @IBOutlet weak var userNameLb: UILabel!
    @IBOutlet weak var subject: UILabel!
    @IBOutlet weak var lineLab: UILabel!
    
    @IBOutlet weak var moneyLb: UILabel!
    @IBOutlet weak var btnBg: UIView!
    @IBOutlet weak var refuseBtn: UIButton!
    @IBOutlet weak var passBtn: UIButton!
    @IBOutlet weak var refuseResonLb: UILabel!//拒绝理由
    @IBOutlet weak var refusePersion: UILabel!//拒绝人
    
    var refuseCallBack : ((_ id:Int) -> Swift.Void)? = nil
    var passCallBack : ((_ id:Int) -> Swift.Void)? = nil
    
    var model : YDOAExpenseAccountModel!{
        didSet{
            guard let model = model else {
                return;
            }
            
            
            if model.status == 2 {
                refuseResonLb.text = "拒绝理由: \(model.refuse_reason ?? "")"
                refusePersion.text = "拒绝人: \(model.ctr_id ?? 0)"
                refusePersion.isHidden = false
                refuseResonLb.isHidden = false
                lineLab.isHidden = true
                refuseBtn.isHidden = true
                passBtn.isHidden = true
            }else if model.status == 1{
                refusePersion.isHidden = true
                refuseResonLb.isHidden = true
                refuseBtn.isHidden = true
                passBtn.isHidden = true
            }else{
                refuseBtn.isHidden = false
                passBtn.isHidden = false
            }
        }
    }
    
    
    /// 拒绝按钮点击
    ///
    /// - Parameter sender:闭包回调
    @IBAction func refuseBtnClick(_ sender: Any) {
        if refuseCallBack != nil {
            refuseCallBack!(model.id!)
        }
    }
    
    /// 通过按钮点击
    ///
    /// - Parameter sender:闭包回调
    @IBAction func passBtnClick(_ sender: Any) {
        if refuseCallBack != nil {
            passCallBack!(model.id!)
        }
    }
    
    override func awakeFromNib() {
        
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
